Skip to content

Conversation

jferrant
Copy link
Contributor

Closes #6368

Originally did this as two configuration options. One in signer, one in node. but it ended up touching more than 40 diff files in a very janky way. Even this change required more modifications than I would like, but I think its better.

@wileyj
Copy link
Collaborator

wileyj commented Aug 14, 2025

testing a 3 miner/signer network with this env var set panics (see below).
the env var was set at 51, and the defined network mode was nakamoto-neon, but it appears that it assumed it was running as mainnet.

ERRO [2025-08-14 19:12:53] [stacks-node/src/main.rs:255] [p2p:(20444,20443)] Process abort due to thread panic: panicked at stacks-common/src/util/mod.rs:179:9:
Cannot use SIGNER_APPROVAL_THRESHOLD env variable with Mainnet.
ERRO [2025-08-14 19:12:53] [stacks-node/src/main.rs:257] [p2p:(20444,20443)] Panic backtrace:    0: stacks_node::main::{{closure}}
             at /code/stacks-core/stacks-node/src/main.rs:256:18
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/boxed.rs:1980:9
      std::panicking::rust_panic_with_hook
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:841:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:699:13
   3: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:168:18
   4: __rustc::rust_begin_unwind
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:697:5
   5: core::panicking::panic_fmt
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/panicking.rs:75:14
   6: stacks_common::util::determine_signer_approval_threshold_percentage
   7: stacks_common::util::compute_voting_weight_threshold
             at /code/stacks-core/stacks-common/src/util/mod.rs:211:21
   8: blockstack_lib::chainstate::nakamoto::NakamotoBlockHeader::verify_signer_signatures
             at /code/stacks-core/stackslib/src/chainstate/nakamoto/mod.rs:897:34
   9: blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::check_nakamoto_block_signer_signature
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:828:47
      blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::is_nakamoto_block_bufferable
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:922:18
      blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::inner_handle_unsolicited_NakamotoBlocksData
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:956:21
      blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::handle_unsolicited_NakamotoBlocksData
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:992:14
      blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::handle_unsolicited_sortition_message
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:1077:26
  10: blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::handle_unsolicited_sortition_messages::{{closure}}::{{closure}}
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:1238:47
      alloc::vec::Vec<T,A>::retain::{{closure}}
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/vec/mod.rs:2157:32
  11: alloc::vec::Vec<T,A>::retain_mut::process_loop
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/vec/mod.rs:2243:21
      alloc::vec::Vec<T,A>::retain_mut
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/vec/mod.rs:2269:9
  12: alloc::vec::Vec<T,A>::retain
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/vec/mod.rs:2157:14
      blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::handle_unsolicited_sortition_messages::{{closure}}
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:1217:22
      hashbrown::map::HashMap<K,V,S,A>::retain
             at /rust/deps/hashbrown-0.15.4/src/map.rs:925:21
  13: std::collections::hash::map::HashMap<K,V,S>::retain
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/collections/hash/map.rs:720:19
      blockstack_lib::net::unsolicited::<impl blockstack_lib::net::p2p::PeerNetwork>::handle_unsolicited_sortition_messages
             at /code/stacks-core/stackslib/src/net/unsolicited.rs:1215:21
      blockstack_lib::net::p2p::PeerNetwork::dispatch_network
             at /code/stacks-core/stackslib/src/net/p2p.rs:5075:39
  14: blockstack_lib::net::p2p::PeerNetwork::run
             at /code/stacks-core/stackslib/src/net/p2p.rs:5589:14
  15: stacks_node::nakamoto_node::peer::PeerThread::run_one_pass
             at /code/stacks-core/stacks-node/src/nakamoto_node/peer.rs:278:22
  16: stacks_node::nakamoto_node::peer::PeerThread::main
             at /code/stacks-core/stacks-node/src/nakamoto_node/peer.rs:112:22
  17: stacks_node::nakamoto_node::StacksNode::spawn::{{closure}}
             at /code/stacks-core/stacks-node/src/nakamoto_node.rs:279:28
      std::sys::backtrace::__rust_begin_short_backtrace
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:152:18
  18: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/thread/mod.rs:559:17
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/panic/unwind_safe.rs:272:9
      std::panicking::catch_unwind::do_call
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:589:40
      std::panicking::catch_unwind
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:552:19
      std::panic::catch_unwind
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panic.rs:359:14
      std::thread::Builder::spawn_unchecked_::{{closure}}
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/thread/mod.rs:557:30
      core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/ops/function.rs:250:5
  19: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/boxed.rs:1966:9
      std::sys::pal::unix::thread::Thread::new::thread_start
             at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/pal/unix/thread.rs:107:17
  20: <unknown>
  21: __clone

Dumping core for pid 1

@wileyj
Copy link
Collaborator

wileyj commented Aug 14, 2025

https://github.com/stacks-network/stacks-core/pull/6375/files#diff-fa401a6f5cd0b77011fc893a6d4cdd2f9d5a69f83df307b0f28885aadbe09d5dR176-R195

i'm not sure here why mainnet is true. CHAIN_ID is also set to 0x80000000 which matches testnet

@jferrant
Copy link
Contributor Author

https://github.com/stacks-network/stacks-core/pull/6375/files#diff-fa401a6f5cd0b77011fc893a6d4cdd2f9d5a69f83df307b0f28885aadbe09d5dR176-R195

i'm not sure here why mainnet is true. CHAIN_ID is also set to 0x80000000 which matches testnet

Was an accidental != vs == I think. Hopefully that is the only spot. Give it a go now and let me know how it goes :D

@aldur aldur linked an issue Aug 21, 2025 that may be closed by this pull request
@aldur aldur moved this to Status: In Review in Stacks Core Eng Aug 21, 2025
@aldur aldur added this to the 3.2.0.0.2 milestone Aug 21, 2025
@aldur aldur marked this pull request as draft August 21, 2025 15:11
@jferrant
Copy link
Contributor Author

Closing. There is a means to achieve similar functionality by manipulating the stacking scripts directly (enables killing of a signer/miner pair with a smaller weight distribution and system still continue chugging. Can always reopen if comes back up.

@jferrant jferrant closed this Sep 22, 2025
@github-project-automation github-project-automation bot moved this from Status: In Review to Status: ✅ Done in Stacks Core Eng Sep 22, 2025
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 99.13420% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.06%. Comparing base (26112c7) to head (76000a1).
⚠️ Report is 718 commits behind head on develop.

Files with missing lines Patch % Lines
stacks-node/src/tests/signer/v0.rs 96.49% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6375      +/-   ##
===========================================
+ Coverage    75.62%   79.06%   +3.43%     
===========================================
  Files          555      555              
  Lines       350915   351039     +124     
===========================================
+ Hits        265365   277533   +12168     
+ Misses       85550    73506   -12044     
Files with missing lines Coverage Δ
libsigner/src/tests/signer_state.rs 97.45% <100.00%> (ø)
libsigner/src/v0/signer_state.rs 84.65% <100.00%> (-0.46%) ⬇️
stacks-common/src/util/mod.rs 93.49% <100.00%> (+4.60%) ⬆️
...tacks-node/src/nakamoto_node/stackerdb_listener.rs 77.39% <100.00%> (-1.82%) ⬇️
stacks-signer/src/chainstate/tests/v2.rs 100.00% <100.00%> (ø)
stacks-signer/src/signerdb.rs 91.56% <100.00%> (+6.87%) ⬆️
stacks-signer/src/tests/signer_state.rs 98.87% <100.00%> (ø)
stacks-signer/src/v0/signer.rs 70.84% <100.00%> (-0.92%) ⬇️
stacks-signer/src/v0/signer_state.rs 71.05% <100.00%> (+4.30%) ⬆️
stackslib/src/chainstate/nakamoto/mod.rs 82.15% <100.00%> (+0.73%) ⬆️
... and 13 more

... and 237 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26112c7...76000a1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[signer] configurable option to lower signer threshold
3 participants